﻿// <copyright file="MachineVirtualRegistryDataHeader.cs" company="Sinclair Community College">
// Copyright 2010 Sinclair Community College
// </copyright>
// <originalAuthor>Patrick S. Seymour (patrick.seymour@gmail.com)</originalAuthor>

namespace SinclairCC.AppV
{
    using System;
    using System.Diagnostics.CodeAnalysis;

    /// <summary>
    /// This class represents the header section of the machine (non-user) registry
    /// data section (section 0x09) in a CP file.
    /// </summary>
    internal class MachineVirtualRegistryDataHeader
    {
        /// <summary>
        /// This field is reserved.
        /// </summary>
        /// <remarks>
        /// For current packages, this field is initialized to 0x00000002.
        /// </remarks>
        [SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Justification = "This field is marked as reserved in the App-V File Format Specification.")]
        private int reserved;

        /// <summary>
        /// The number of entry blocks following the header block.
        /// </summary>
        private int entryCount;

        /// <summary>
        /// The byte size of the string-table that follows immediately
        /// after the registry entry blocks.
        /// </summary>
        private int stringTableSize;

        /// <summary>
        /// Initializes a new instance of the MachineVirtualRegistryDataHeader class.
        /// </summary>
        /// <param name="streamReader">
        /// A binary reader that contains the raw header data.
        /// </param>
        public MachineVirtualRegistryDataHeader(System.IO.BinaryReader streamReader)
        {
            this.reserved = streamReader.ReadInt32();
            this.entryCount = streamReader.ReadInt32();
            this.stringTableSize = streamReader.ReadInt32();
        }

        /// <summary>
        /// Gets the number of registry entry blocks that follow the header.
        /// </summary>
        public int EntryCount
        {
            get { return this.entryCount; }
        }

        /// <summary>
        /// Gets the size, in bytes, of the string table that follows the list
        /// of registry entry blocks.
        /// </summary>
        public int StringTableSize
        {
            get { return this.stringTableSize; }
        }
    }
}
